﻿@using Novagoal.Website.Models.Views
@using Novagoal.Website.WebApp.Helpers
@using Novagoal.Utils
@using Ids.Web.Security

@model GamesViewModel
@{
    ViewBag.Title = string.Format("Novagoal | {0} Game", Model.Game.Id == 0 ? "Add" : "Edit");
    Layout = "~/Views/Shared/MasterLayout.cshtml";
}
@section PageContent {
    <script src="@Url.Content("~/Scripts/novagoal-games.js")" type="text/javascript"></script>
    <div class="main-content ui-corner-top">
        <div class="ui-widget-header ui-corner-all">
            <div class="title">@string.Format("{0} Game", Model.Game.Id == 0 ? "Add" : "Edit")</div>
        </div>
        @{Html.RenderPartial("SubmitResults"); }
        <div class="ui-widget-content ui-corner-bottom">
            @using (Html.BeginForm("Save", "Games", FormMethod.Post, new { id = "newGameForm" }))
            {
                <input type="hidden" id='GameId' name='GameId' value='@Model.Game.Id' />
                <fieldset class='formContent'>
                <legend>Game Information</legend>
                    <div class='formColumn'>
                        @Html.Label("Tournament *")
                        @{var tournamentId = Model.Game.Tournament != null ? Model.Game.Tournament.Id : 0;}                  
                        @Html.DropDownList("TournamentId", new SelectList(Model.Tournaments, "Id", "Name", tournamentId), "Select one")
                        <br />
                        @Html.Label("Start At *")
                        @Html.TextBox("StartAt", Model.Game.StartedAt.ToString("MM/dd/yyyy HH:mm"), new { @class = "dateTime" })
                    </div>
                    <div class='formColumn'>
                        @Html.Label("Local Team *")
                        @{var teamAId = Model.Game.TeamA != null ? Model.Game.TeamA.Id : 0;}                  
                        @Html.DropDownList("TeamAId", new SelectList(Model.Teams, "Id", "Name", teamAId), "Select one")
                        <br />
                        @Html.Label("Visit Team *")
                        @{var teamBId = Model.Game.TeamB != null ? Model.Game.TeamB.Id : 0;}                  
                        @Html.DropDownList("TeamBId", new SelectList(Model.Teams, "Id", "Name", teamBId), "Select one")
                    </div>
                </fieldset>
                <br />
                <div style='text-align:center'>
                    <input type="submit" value="Save" class='button' />
                </div>
            }
        </div>
    </div>
}
